#encoding : utf8

import os, sys
import  pymysql,threading
import time, linecache,random
from  multiprocessing import  Process, Pool

__author = 'Avatar'

#开启线程轮询
class MyThread(threading.Thread):
	def  run(self):
		for i in range(3):
			time.sleep(1)
			msg = 'thread'
			print(msg)
def  test():
	for i in range(3):
		t = MyThread()
		t.start()
		if i == 2:
			t.sleep()
			print('sleep')

def run_proc(name):
    print('run child process %s (%s)' %(name, os.getpid()))# Return the current process id

# transform file's encoding
def transformCoding(fdir_r,fdir_w,ec_r,ec_w):
    fr = open(fdir_r, 'r+',encoding=ec_r)
    flst = fr.readlines()
    fr.close()
    fw = open(fdir_w, 'w+',encoding=ec_w)
    fw.writelines(flst)
    fw.close()



# 系统的参数
def sys_args():
    args = sys.argv
    if len(args) == 1:
        print('one argument')
    elif len(args) == 2:
        print(args[1])
    else:
        print('too many arguments')
#time.time()

if __name__ == '__main__':
    dr = 'G:\思贤\jinhua\stuff\金华复盘\data/rate_201607_short.csv'
    dw = 'G:\思贤\jinhua\stuff\金华复盘\data/rate_201607_short_gbk.csv'
    ecr = 'utf8'
    ecw = 'gbk'
    transformCoding(dr,dw,ecr,ecw)
